import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import { systemid, productid } from '../../atom/config';
import query from '@dfeidao/atom-nodejs/db/query';

interface Message {
	filter: {
		optional_value: string,
	}
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}
interface Par {
	value_no: string
}
export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:e:\Feidao\kh\src\risk-point\zj-000010\s002,action_id:' + action_id);
	//风险等级下拉框
	const { prepare, exec } = query(action_id, session_id, systemid);
	prepare('basic_data', ['value_title', 'value_no'], { productid, value_title: "区域" }, 20, 1, [], []);
	const d = await exec<Par>();
	const data = d[0];

	prepare('property_optional_values', ['value_no', 'optional_value', 'priority'], { productid, value_no: data[0].value_no }, 20, 1, [], []);
	const [res] = await exec();
	log('Service end path:e:\Feidao\kh\src\risk-point\zj-000010\s002,action_id:' + action_id);
	return {
		data: {
			res
		}
	};
}
